define(["jquery", "easy-admin"], function ($, ea) {
    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'merchant/index',
        add_url: 'merchant/add',
        edit_url: 'merchant/edit',
        delete_url: 'merchant/delete',
        export_url: 'merchant/export',
        modify_url: 'merchant/modify',
    };
    var Controller = {
        index: function () {
            ea.table.render({
                init: init,
                toolbar: ['refresh',
                [
                    {
                            text: '添加',
                            url: init.add_url,
                            method: 'open',
                            auth: 'add',
                            class: 'layui-btn layui-btn-normal layui-btn-sm',
                            icon: 'fa fa-plus ',
                            extend: 'data-full="true"',
                        }
                    ],
                ],
                cols: [[
                    {field: 'id', title: 'id', search: false},
                    {field: 'merchant_name', title: '商户名称'},
                    {field: 'main_image', minWidth: 80, title: '图片', search: false, templet: ea.table.image}, 
                    {field: 'phone', title: '联系电话'},
                    {field: 'position', title: '店铺位置', search: false},
                    // {field: 'longitude', title: '经度', search: false},
                    // {field: 'latitude', title: '纬度', search: false},
                    {field: 'qrcode', minWidth: 80, title: '推广码', search: false, templet: ea.table.image}, 
                    {field: 'create_time', title: '入驻时间', search: false},
                    {
                        width: 250,
                        title: '操作',
                        templet: ea.table.tool,
                        operat: [
                            [
                                {
                                    text: '编辑',
                                    url: init.edit_url,
                                    method: 'open',
                                    auth: 'edit',
                                    class: 'layui-btn layui-btn-success layui-btn-xs',
                                    extend: 'data-full="true"',
                                }
                            ],'delete'
                        ]
                    }

                ]],
            });
            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
    };
    return Controller;
});